#include "msp430g2553.h"
#include "ChaosCube.h"

void initAudio()
{
	// Initialize pins to low logic
    PxOUT_AUDIO_SEL &= ~(P_AUDIO_SEL_0 + P_AUDIO_SEL_1 + P_AUDIO_SEL_2);
    // Set P1 audio pins to output direction
    PxDIR_AUDIO_SEL |= (P_AUDIO_SEL_0 + P_AUDIO_SEL_1 + P_AUDIO_SEL_2);
    // Initialize Enable at 0
	PxOUT_AUDIO_ENABLE &= ~(P_AUDIO_ENABLE);
	// Set P3 Enable pin to output direction
	PxDIR_AUDIO_ENABLE |= (P_AUDIO_ENABLE);

	return;
}


void sendAudio(int face)
{
	// Initialize pins to low logic
	PxOUT_AUDIO_SEL &= ~(P_AUDIO_SEL_0 + P_AUDIO_SEL_1 + P_AUDIO_SEL_2);


	PxOUT_AUDIO_SEL |= (face << AUDIO_SEL_OFFSET);

	// start audio enable signal (this enables the 3:8 demux)
	PxOUT_AUDIO_ENABLE |= P_AUDIO_ENABLE;

	//Wait for Signal to propagate
	delay_ms(100);
	//Disable Demux
	PxOUT_AUDIO_ENABLE &= ~(P_AUDIO_ENABLE);
	return;
}

 

